package com.shunhao.mvp

import android.os.Bundle
import com.shunhao.base.BaseActivity

/**
 *类作用描述:   纯Mvp模式不添加额外代码 后期会拓展MvvM
 *@author      KangGuiYang
 *创建时间      2020/6/15 14:14
 *邮箱        kangguiyang2@gmail.com
 *公司        南京舜贝佳信息科技 Shunbega.com
 */
abstract class BaseMvpActivity<P : BasePresenter<Any?>?> : BaseActivity() {

    var mPresenter: P? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        mPresenter = createPresenter()
        mPresenter?.attachView(this)
        super.onCreate(savedInstanceState)
    }

    override fun onDestroy() {
        super.onDestroy()
        //presenter断开与界面的联系
        mPresenter?.detachView()
    }


    /**
     * 创建Presenter
     * @return 返回一个Presenter对象
     */
    protected abstract fun createPresenter(): P?


}